using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Web.UI;

namespace Alogient.Cameleon.Forms.Sdk.Items
{
    public class Submission
    {
        public int ID { get; private set; }
        public int FormID { get; private set; }
        public DateTime SubmissionDate { get; private set; }
        public string IP { get; set; }
        public string UserAgent { get; set; }
        public string ReferenceUrl { get; set; }
        public string PageUrl { get; set; }
        public string CultureCode { get; set; }
        public string Email { get; set; }
        public object UserPKID { get; set; }
        public string UserName { get; set; }
        public Alogient.Cameleon.Sdk.UI.WebControls.CMForm CMForm = null;

        public Submission(int formID)
        {
            Email = string.Empty;
            CultureCode = string.Empty;
            PageUrl = string.Empty;
            ReferenceUrl = string.Empty;
            UserAgent = string.Empty;
            IP = string.Empty;
            SubmissionDate = DateTime.Now;
            ID = 0;
            UserPKID = null;
            UserName = string.Empty;
            FormID = formID;
        }

        List<SubmissionValue> _values = new List<SubmissionValue>();

        public List<SubmissionValue> values
        {
            get
            {
                return _values;
            }
        }

        public bool Save()
        {
            if (this.ID == 0) 
            {
                // New Submission
                throw new NotImplementedException("Not implemented"); // TODO

                //foreach (SubmissionValue value in values)
                //{
                //    value.SubmissionID = ID;
                //    value.Save();
                //}

                //return true;
            }

            return false;
        }
    }
}
